package cn.wolfcode.blog.controller;

import cn.wolfcode.blog.resp.Result;
import cn.wolfcode.blog.service.ICommentService;
import cn.wolfcode.blog.vo.CommentVo;
import cn.wolfcode.blog.vo.ReplyVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/comments")
public class CommentController {

    @Autowired
    private ICommentService commentService;

    @GetMapping
    public Result query() {
        List<CommentVo> comments = commentService.query();
        return Result.success(comments);
    }

    @PostMapping
    public Result create(ReplyVo vo) {
        commentService.create(vo);
        return Result.success();
    }
}
